home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / SkinnedMesh / skinmesh4.vsh < prev    next >
Encoding:
Text File  |  2004-09-27  |  2.6 KB  |  110 lines

  1.  
  2. vs.1.1
  3.  
  4. ;------------------------------------------------------------------------------
  5. ; v0 = position
  6. ; v1 = blend weights
  7. ; v2 = blend indices
  8. ; v3 = normal
  9. ; v4 = texture coordinates
  10. ;------------------------------------------------------------------------------
  11.  
  12. ;------------------------------------------------------------------------------
  13. ; r0.w = Last blend weight
  14. ; r1 = Blend indices
  15. ; r2 = Temp position
  16. ; r3 = Temp normal
  17. ; r4 = Blended position in camera space
  18. ; r5 = Blended normal in camera space
  19. ;------------------------------------------------------------------------------
  20.  
  21. ;------------------------------------------------------------------------------
  22. ; Constants specified by the app;
  23. ;
  24. ; c9-c95 = world-view matrix palette
  25. ; c8      = diffuse * light.diffuse
  26. ; c7      = ambient color
  27. ; c2-c5   = projection matrix
  28. ; c1      = light direction
  29. ; c0      = {1, power, 0, 1020.01};
  30. ;------------------------------------------------------------------------------
  31.  
  32. ;------------------------------------------------------------------------------
  33. ; oPos      = Output position
  34. ; oD0      = Diffuse
  35. ; oD1      = Specular
  36. ; oT0      = texture coordinates
  37. ;------------------------------------------------------------------------------
  38.  
  39. dcl_position v0;
  40. dcl_blendweight v1;
  41. dcl_blendindices v2;
  42. dcl_normal v3;
  43. dcl_texcoord0 v4;
  44.  
  45. // Compensate for lack of UBYTE4 on Geforce3
  46. mul r1,v2.zyxw,c0.wwww
  47. //mul r1,v2,c0.wwww
  48.  
  49.  
  50. //first compute the last blending weight
  51. dp3 r0.w,v1.xyz,c0.xxx; 
  52. add r0.w,-r0.w,c0.x
  53.  
  54. //Set 1
  55. mov a0.x,r1.x
  56. m4x3 r4.xyz,v0,c[a0.x + 9];
  57. m3x3 r5.xyz,v3,c[a0.x + 9]; 
  58.  
  59. //blend them
  60. mul r4.xyz,r4.xyz,v1.xxxx
  61. mul r5.xyz,r5.xyz,v1.xxxx
  62.  
  63. //Set 2
  64. mov a0.x,r1.y
  65. m4x3 r2.xyz,v0,c[a0.x + 9];
  66. m3x3 r3.xyz,v3,c[a0.x + 9];
  67.  
  68. //add them in
  69. mad r4.xyz,r2.xyz,v1.yyyy,r4;
  70. mad r5.xyz,r3.xyz,v1.yyyy,r5;
  71.         
  72. //Set 3
  73. mov a0.x,r1.z
  74. m4x3 r2.xyz,v0,c[a0.x + 9];
  75. m3x3 r3.xyz,v3,c[a0.x + 9];
  76.  
  77. //add them in
  78. mad r4.xyz,r2.xyz,v1.zzzz,r4;
  79. mad r5.xyz,r3.xyz,v1.zzzz,r5;
  80.  
  81. //Set 4
  82. mov a0.x,r1.w
  83. m4x3 r2.xyz,v0,c[a0.x + 9];
  84. m3x3 r3.xyz,v3,c[a0.x + 9];
  85.  
  86. //add them in
  87. mad r4.xyz,r2.xyz,r0.wwww,r4;
  88. mad r5.xyz,r3.xyz,r0.wwww,r5;
  89.  
  90. //compute position
  91. mov r4.w,c0.x
  92. m4x4 oPos,r4,c2
  93.  
  94. // normalize normals
  95. dp3 r5.w, r5, r5;
  96. rsq r5.w, r5.w;
  97. mul r5, r5, r5.w;
  98.  
  99. ; Do the lighting calculation
  100. dp3 r1.x, r5, c1      ; normal dot light
  101. lit r1, r1
  102. mul r0, r1.y, c8      ; Multiply with diffuse
  103. add r0, r0, c7        ; Add in ambient
  104. min oD0, r0, c0.x     ; clamp if > 1
  105. mov oD1, c0.zzzz     ; output specular
  106.  
  107. ; Copy texture coordinate
  108. mov oT0, v4
  109.  
  110.